<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path;
%>
<fieldset class="fieldset">
	<legend>Excel导入导出</legend>
	<div class="info-panel">

		<div id="adjustImportBtn">

			<a href="javascript:uploadDialog()" class="easyui-linkbutton"
				style="width: 80px; margin-top: 1em">导入excel</a> <em class="m5"></em>
			<a href="javascript:exportexcel()" class="easyui-linkbutton"
				style="width: 80px; margin-top: 1em">导出excel</a>
		</div>

	</div>
	<div id="uploadDialog"></div>
</fieldset>
<fieldset class="fieldset">
	<legend>图片上传</legend>
	<div class="info-panel">
	 <input type="file" id="file_upload" name="files">    
		<!-- <div id="file_upload"></div> -->
		<div id="uploadfileQueue" style="padding: 3px;"></div>
		<span id="spanupload">
			<button type="button" id="P_Add" onclick="doUplaod()"
				class="easyui-linkbutton" style="cursor: pointer; width: 80px;">上传</button>
			<button type="button" id="P_Del" onclick="closeLoad()"
				class="easyui-linkbutton"
				style="cursor: pointer; width: 80px; margin-left: 10px;">取消上传</button>
		</span>
	</div>
	<div id="uploadDialog"></div>
</fieldset>
<link href="<%=basePath%>/Plugins/uploadify/uploadify.css"
	rel="stylesheet" />
<script src="<%=basePath%>/Plugins/uploadify/swfobject.js"></script>
<script src="<%=basePath%>/Plugins/uploadify/jquery.uploadify.min.js"></script>
<script type="text/javascript">
$(function() {
	//[start]
	 $("#file_upload").uploadify({
         'debug': false, //开启调试
         'auto': false, //是否自动上传
         'swf': "<%=basePath%>/Plugins/uploadify/uploadify.swf", //flash
         'buttonText': '选择图片',
         'queueID': 'uploadfileQueue', //文件选择后的容器ID
         'uploader': '<%=basePath%>/system/user/uploadimgae', //上传处理程序
         'width': '75',
         'height': '24',
         'multi': true, //多图片上传
         'fileTypeDesc': '支持的格式：',
         'fileExt': '*.jpg;*.jpge;*.gif;*.png', //允许上传的文件后缀
         'fileDesc ': 'Web Image Files (.JPG,.JPGE,.GIF, .PNG)',
         'fileObjName' : 'files',
         //'folder': 'UploadFile',
         'fileSizeLimit': '8MB', //限定文件大小<img src="" />
         'successTimeout': 3000, //上传超时时间
         'queueSizeLimit': 100, //上传数量
         //'formData': { 'ProductCode': $('#hfCategoryID').val(), 'type': 'UploadCategoryimage' }, //上传参数
         'onUploadStart': function (file) {
             //校验
            // $("#file_upload").uploadify("settings", "formData", { 'ProductCode': name, 'type': 'UploadCategoryimage' });
         },
         //返回一个错误，选择文件的时候触发
         'onSelectError': function (file, errorCode, errorMsg) {
             switch (errorCode) {
                 case -100:
                     alert("上传的文件数量已经超出系统限制的" + $('#file_upload').uploadify('settings', 'queueSizeLimit') + "个文件！");
                     break;
                 case -110:
                     alert("文件 [" + file.name + "] 大小超出系统限制的" + $('#file_upload').uploadify('settings', 'fileSizeLimit') + "大小！");
                     break;
                 case -120:
                     alert("文件 [" + file.name + "] 大小异常！");
                     break;
                 case -130:
                     alert("文件 [" + file.name + "] 类型不正确！");
                     break;
             }
         },
         //检测FLASH失败调用
         'onFallback': function () {
             alert("您未安装FLASH控件，无法上传图片！请安装FLASH控件后再试。");
         },
         //上传到服务器，服务器返回相应信息到data里
         'onUploadSuccess': function (file, data, response) {
             //文件上传成功后实现预览
             if (data != "") {
                 var ThisDt = $.parseJSON(data);
                 if (ThisDt.success == "true") {
                     $('#imag_update').attr('src', ThisDt.url);
                 } else {
                     ERP_alert(ThisDt.url);
                 }
             }
         }
     });
	//[end]
})
  function doUplaod() {
        $('#file_upload').uploadify('upload', '*');
    }

    function closeLoad() {
        $('#file_upload').uploadify('cancel', '*');
    }
function exportexcel() {
	window.location.href = "<%=basePath%>/system/other/exportexcel";
}
function uploadDialog() {
    $("#uploadDialog").dialog({
        title: '上传',
        width: '30%',
        height: '20%',
        closed: false,
        cache: false,
        href: "<%=basePath%>/system/other/upladexcel",
			modal : true
		});
	}
</script>